#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
    扩展类的功能，插件类. 对象方法赋值
'''

class Person():
    def __init__(self, name):
        self.name = name

    def walk(self):
        print('行走')


class StudyMixin():
    def study(self):
        print(self.name + '...在上课...'   )

def extend_klass(klass, klass_src):
    for method in dir(klass_src):
        if not method.startswith('_'):
            setattr(klass, method, getattr(klass_src, method))
    pass

class Student(Person):
    def __init__(self, name,age):
        Person.__init__(self,name)
        self.age=age

    def eat(self):
        print(self.name + '...在吃饭...')

extend_klass(Student, StudyMixin)


Student('小明',10).study()
# StudyMixin().study()
# >>> AttributeError: 'StudyMixin' object has no attribute 'name'
